package OrderService

import (
	"context"
	"gdshop-back-end-go/client-api/app/request/OrderReq"
	commonOrderReq "gdshop-back-end-go/common/request/OrderReq"
	"gdshop-back-end-go/common/response"
	"gdshop-back-end-go/service-order/OrderService"
)

// 用户关闭订单 判断状态，必须是 1待付款 才可以关闭订单
func Close(ctx context.Context, parames *OrderReq.Close) *response.JsonResponse {
	if !IsMyOrder(ctx, parames.Id, int(parames.MemberId)) {
		return response.FailByRequestMessage(nil, "请勿操作别人的订单")
	}

	return OrderService.MemberCloseOrder(ctx, &commonOrderReq.MemberCloseOrder{
		OrderId:  parames.Id,
		MemberId: parames.MemberId,
		Remark:   parames.Remark,
	})
}
